#ifndef MYQGRAPHICSCENE_H
#define MYQGRAPHICSCENE_H

#include <QGraphicsScene>
#include <QGraphicsItem>
#include "../common.h"
class MyQGraphicScene : public QGraphicsScene
{
    Q_OBJECT
public:
    enum Mode { InsertNone, InsertItem, InsertLine, InsertText, MoveItem };
    explicit MyQGraphicScene(QObject *parent = nullptr);
    void addNode(eSelectShape eType, QPointF point);
    void setPos(QPointF point);
protected:
    void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
    void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) override;
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
signals:
    void sigChangeCur(bool);
private:
    bool bPointOnLine(QLineF line, QPointF pointToCheck);
    bool bChangeDirection(MouseMoveDirect);
    void changePoint(MouseMoveDirect, QPointF, QPointF&);
    MouseMoveDirect determineDirection(const QPointF& delta);
    MouseMoveDirect getEndDiection(QPointF curPoint, QPointF& delta);
    QGraphicsItem*    m_curGrapViewItem;
    Mode              m_eMode;
    bool              m_bMousePressed;
    QPointF           lastPos;
    QPointF           m_startPos;
    QPainterPath      linePath;
    QGraphicsPathItem *pathItem;
    QList<QPointF>    points;
    MouseMoveDirect   m_PreMouseDirect;
    MouseMoveDirect   m_StartDirect;
    MouseMoveDirect   m_EndDirect;

};

#endif // MYQGRAPHICSCENE_H
